﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Mendel;

namespace SimpleMendelInterpreter
{
    class Program
    {
        static void Main(string[] args)
        {
            Processor proc = new Processor();
            Mendel.BuiltInWords.AddAll();

            string input = "";

            Console.WriteLine("Simple Mendel Interpreter to test the language\nmade by Ratatics Dániel\n\n");

            while (!input.Equals("exit"))
            {
                Console.Write("> ");
                input=Console.ReadLine();
                
                if (input.Equals("exit"))
                    return;

                proc.Run(input, -1);
                Console.WriteLine(proc.Output);
                proc.ClearOutput();
                if (Universe.GetErrorNumber() == 0)
                {
                    Console.WriteLine("ok.");
                }
                else
                {
                    List<Error> tmp = Universe.GetAllErrors(true);
                    Console.WriteLine("errors:");
                    foreach (Error item in tmp)
                    {
                        Console.WriteLine("{0} {1} {2}", item.TaskId, item.Time, item.e.Message);
                    }
                }
            }

        }
    }
}
